package com.ysd.lis.controller.qi;


import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.qi.QiDatabase;
import com.ysd.lis.request.qi.DatabaseDto;
import com.ysd.lis.request.qi.DatabaseParam;
import com.ysd.lis.service.qi.QiDatabaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 指标项目条件表 前端控制器
 * </p>
 *
 * @author PRS
 * @since 2024-07-01
 */
@Api(tags = "指标项目条件")
@RestController
@RequestMapping("/api/qi/qiDatabase")
public class QiDatabaseController extends BaseController {

    @Autowired
    QiDatabaseService qiDatabaseService;

    @ApiOperation("查询")
    @GetMapping("/findQiDatabaseList")
    public Result findQiDatabaseList(DatabaseParam param){
        return qiDatabaseService.findQiDatabaseList(param);
    }

    @ApiOperation("新增")
    @PostMapping("/addDatabase")
    public Result addDatabase(@RequestBody QiDatabase qiDatabase){
        return  qiDatabaseService.addDatabase(qiDatabase);
    }

    @ApiOperation("修改")
    @PostMapping("/editDatabase")
    public Result editDatabase(@RequestBody QiDatabase qiDatabase) {
        return qiDatabaseService.editDatabase(qiDatabase);
    }

    @ApiOperation("批量删除")
    @PostMapping("/batchDeleteDatabaseList")
    public Result batchDeleteDatabaseList(@RequestBody DatabaseDto dto){
        return  qiDatabaseService.batchDeleteDatabaseList(dto);
    }

    @PostMapping("/qiDatabaseConnection")
    public Result qiDatabaseConnection(@RequestBody QiDatabase qiDatabase) {
        return qiDatabaseService.qiDatabaseConnection(qiDatabase);
    }

    /**
     * 通过连接获取所有表信息
     * @param qiDatabaseId
     * @return
     */
    @GetMapping("/qiDatabaseGetTables")
    public Result qiDatabaseGetTables(@RequestParam("qiDatabaseId")String qiDatabaseId) {
        return qiDatabaseService.qiDatabaseGetTables(qiDatabaseId);
    }
    /**
     * 通过表获取字段
     * @param qiDatabase
     * @return
     */
    @PostMapping("/qiDatabaseGetFieldByTables")
    public Result qiDatabaseGetFieldByTables(@RequestBody QiDatabase qiDatabase) {
        return qiDatabaseService.qiDatabaseGetFieldByTables(qiDatabase);
    }
    /**
     * 通过表获取字段
     * @param qiDatabase
     * @return
     */
    @PostMapping("/getQiDatabaseTableFieldList")
    public Result getQiDatabaseTableFieldList(@RequestBody QiDatabase qiDatabase) {
        return qiDatabaseService.getQiDatabaseTableFieldList(qiDatabase);
    }

}
